import type { User,CodeType, UserInfo, PatientList, Patient } from "@/types/user";
import { request } from "@/utils/request";

// 密码登录
export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', { mobile, password })
}
// 发送验证码
export const sendMobileCode = (mobile:string ,type:CodeType)=>{
  return request('/code','GET',{mobile,type})
}
// 短信登录
export const loginByMobile = (mobile:string,code:string)=>{
  return request<User>('/login','post',{mobile,code})
}
// 获取用户信息
export const getUserInfo = ()=> request<UserInfo>('patient/myUSer')

// 获取患者列表信息
export const getPatientList =()=> request<PatientList>('/patient/mylist')

// 添加患者
export const addPatient = (patient: Patient) => {
  return request('/patient/add', 'POST', patient)
}
// 编辑患者信息
export const editPatient = (patient: Patient) => {
  return request('/patient/update', 'PUT', patient)
}
// 删除患者信息
export const delPatient = (id:string)=> request(`/patient/del/${id}`, 'DELETE')

// 患者详情信息
export const getPatientDetail = (id:string)=> request<Patient>(`/patient/info/${id}`)

// 获取未读消息数量
export const getUnreadMessageCount = ()=>request<number>('patient/message/unRead/all')
